package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysUserInvite;
import com.ruoyi.system.service.ISysUserInviteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 邀请用户审批Controller
 *
 * @author ruoyi
 * @date 2024-04-15
 */
@RestController
@RequestMapping("/system/user/invite")
public class SysUserInviteController extends BaseController
{
    @Autowired
    private ISysUserInviteService sysUserInviteService;

    /**
     * 查询邀请用户审批列表
     */
    @PreAuthorize("@ss.hasPermi('system:invite:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody SysUserInvite sysUserInvite)
    {
        setStartPage(sysUserInvite.getPageNum(),sysUserInvite.getPageSize());
        List<SysUserInvite> list = sysUserInviteService.selectSysUserInviteList(sysUserInvite);
        return getDataTable(list);
    }

    /**
     * 获取邀请用户审批详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:invite:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysUserInviteService.selectSysUserInviteById(id));
    }

    /**
     * 新增邀请用户审批
     */
    @PreAuthorize("@ss.hasPermi('system:invite:add')")
    @Log(title = "邀请用户审批", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserInvite sysUserInvite)
    {
        return toAjax(sysUserInviteService.insertSysUserInvite(sysUserInvite));
    }

    /**
     * 修改邀请用户审批
     */
    @PreAuthorize("@ss.hasPermi('system:invite:edit')")
    @Log(title = "邀请用户审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserInvite sysUserInvite)
    {
        return toAjax(sysUserInviteService.updateSysUserInvite(sysUserInvite));
    }

}
